# coding: utf-8
from wxpy import Bot, Chat
import math
import os

 
class WxFriendImage(Chat):
    @staticmethod
    def get_image():
        path = os.path.abspath(".")
        bot = Bot()  # 机器人对象
        friends = bot.friends(update=True)
 
        dirs = path + "\\wxImages"
        if not os.path.exists(dirs):
            os.mkdir("wxImages")
 
        index = 0
        for friend in friends:
            print(f"正在保存{friend.nick_name}的微信头像")
            friend.get_avatar(dirs + "\\" + f"{str(index)}.jpg")
            index += 1
 
        return dirs
 
def main():
    dirs = WxFriendImage.get_image()
    WxFriendImage.composite_image(dirs)
if __name__ == '__main__':
    main()